<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>软件下载</title>
    <link href="apps_res/download/css/his_down.css" rel="stylesheet" type="text/css">
    <script src="common/js/jquery.min.js" type="text/javascript"></script>
</head>
<body @load="bodyLoad">
<div id="app">
    <div class="ly_shadow" style="display:none;" id="shadow">
        <img src="apps_res/download/images/arrow.png" alt="">
        <h1>如何下载中原证券移动协同</h1>
        <div class="det">
            <p><em>1</em> 点击右上角 · · · 按钮</p>
            <p><em>2</em> 选择“在浏览器中打开”</p>
        </div>
    </div>

    <!--ios微信用户  start-->
    <div class="ly_shadow" style="display:none;" id="iosdow">
        <img src="apps_res/download/images/arrow.png" alt="">
        <h1>如何下载中原证券移动协同</h1>
        <div class="det">
            <p><em>1</em> 点击右上角 · · · 按钮</p>
            <p><em>2</em> 选择“在Safari中打开”</p>
        </div>
    </div>
    <!--ios微信用户  end-->

    <div class="page" id="show_download">
        <div class="header">
            <a href="javascript:void(0)" class="logo">
                <img :src="download.logoUrl" alt="" />
            </a>
            <span class="title">
			软件下载
		</span>
        </div>

        <div class="main">
            <div class="main_cen">
                <img :src="download.appLogoUrl" />
                <p style="word-break:break-all;width: 230px;margin: 0 auto;">版本描述：{{download.app_version}}
                    <br />{{download.description}}
                </p>
                <a v-if="download.android_url!=''" :href="download.android_url" class="android" @click="download_an">android下载</a>
                <a v-if="download.iphStoreUrl != '' || download.plistUrl" :href="download.android_url" class="apple"
                   @click="download_ios">iPhone下载</a>
                <div id="his_version">
                    <a :href="'/history.html?custId='+download.id"
                       id="history">历史版本</a>
                </div>
            </div>
        </div>
    </div>
    <div style="display:none;" id="show_ios">
        <img src="apps_res/download/images/ios.gif" style="width:100%;">
    </div>
</div>
<script src="http://apps.bdimg.com/libs/vue/1.0.14/vue.js"></script>
<script>
    function getParmKeyValue() {
        var parmArr = location.search.substr(1).split("&");
        var parmsObj = {};
        for (index in parmArr) {
            var parm = parmArr[index].split("=");
            parmsObj[parm[0]] = parm[1];
        }
        return parmsObj;
    }

    var parmMap = getParmKeyValue();

    /**
     * 参数名获取参数值
     *
     * @param parmName
     * @returns {*}
     */
    function getParm(parmName) {
        return parmMap[parmName];
    }


    var download = {};
    //获取数据
    $.ajax({
        url: "/appAction",
        dataType: "json",
        async: false,
        data: {
            method: "download",
            custId: getParm("custId") == undefined ? "" : getParm("custId"),
            appVersion: getParm("appVersion") == undefined ? "" : getParm("appVersion")
        },
        type: "post",
        success:

            function (result) {
                if (result.success) {
                    download = result.obj;
                } else {
                    alert(result.errMsg);
                }
            }
    });
    var vm = new Vue({
        el: '#app',
        data: {
            download: download
        },
        method: {
            bodyLoad: function () {
                var u = navigator.userAgent,
                    app = navigator.appVersion;
                var versions = { //移动终端浏览器版本信息
                    trident: u.indexOf('Trident') > -1, //IE内核
                    presto: u.indexOf('Presto') > -1, //opera内核
                    webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                    mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
                    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
                    iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
                    iPad: u.indexOf('iPad') > -1, //是否iPad
                    webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                    weixin: u.indexOf('MicroMessenger') > -1 //是否为微信浏览器
                };
                var language = (navigator.browserLanguage || navigator.language).toLowerCase();
                if (versions.ios || versions.iPhone || versions.iPad) {
                    if (versions.weixin) {
                        document.getElementById("iosdow").style.display = "";
                    }
                } else if (versions.android) {
                    var url = download.android_url;
                    if (versions.weixin) {
                        document.getElementById("shadow").style.display = "";
                    }
                    try {
                        if (download.android_url == '') {
                            document.location.href = url;
                        }

                    } catch (e) {
                        if (!download.android_url == '') {
                            document.location.href = url;
                        }
                    }
                }
            },
            download_ios: function () {
                var url = "";
                if (download.plistUrl != '') {
                    url = "itms-services:///?action=download-manifest&url=https://www.cdmkkj.cn:8843+" + "" + download.plistUrl;
                }
                if (download.iphStoreUrl != '') {
                    url = download.iphStoreUrl;
                }
                try {
                    window.location = url;
                } catch (e) {
                    try {
                        window.location = url;
                    } catch (e) {

                    }
                }
            },
            download_an: function () {
                try {
                    document.location.href = download.android_url;
                } catch (e) {
                    try {
                        document.location.href = download.android_url;
                    } catch (e) {

                    }
                }
            }
        }
    })
</script>
</body>
</html>